Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix directory separator in ProcessResource attributes #6716

Merged
merged 3 commits into from
Sep 26, 2022
Merged

Fix directory separator in ProcessResource attributes #6716

merged 3 commits into from
Sep 26, 2022

Conversation

fcrespel
Copy link
Contributor

The separator char used to build the Java executable path in ProcessResource is wrong: File.pathSeparatorChar is the PATH variable separator (: on Linux, ; on Windows), the right one for directories is File.separatorChar (/ on Linux, \ on Windows).

Note that this issue was already present in sdk-extensions-resources before it was moved here; should it be fixed there too?

@fcrespel fcrespel requested a review from a team September 22, 2022 21:36
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 22, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: fcrespel / name: Fabien Crespel (8c791b9)

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @fcrespel! can you see if it's not too hard to add a test for this?

Note that this issue was already present in sdk-extensions-resources before it was moved here; should it be fixed there too?

cc @jack-berg

@fcrespel
Copy link
Contributor Author

@trask I updated the existing tests in ProcessResourceTest to include the directory separator, is that OK for you?

@@ -29,7 +30,7 @@ void notWindows() {

assertThat(attributes.get(ResourceAttributes.PROCESS_PID)).isGreaterThan(1);
assertThat(attributes.get(ResourceAttributes.PROCESS_EXECUTABLE_PATH))
.contains("java")
.contains(File.separatorChar + "java")
Copy link
Member

@trask trask Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like .matches("[/\\]java")? e.g. to avoid the test verification relying on the same logic that we missed previously

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the tests accordingly.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @fcrespel1

@trask trask merged commit 7cb57e1 into open-telemetry:main Sep 26, 2022
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this pull request Oct 23, 2022
…#6716)

The separator char used to build the Java executable path in
ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable
separator (`:` on Linux, `;` on Windows), the right one for directories
is `File.separatorChar` (`/` on Linux, `\` on Windows).

Note that this issue was already present in
[sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64)
before it was moved here; should it be fixed there too?
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this pull request Oct 31, 2022
…#6716)

The separator char used to build the Java executable path in
ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable
separator (`:` on Linux, `;` on Windows), the right one for directories
is `File.separatorChar` (`/` on Linux, `\` on Windows).

Note that this issue was already present in
[sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64)
before it was moved here; should it be fixed there too?
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this pull request Dec 4, 2022
…#6716)

The separator char used to build the Java executable path in
ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable
separator (`:` on Linux, `;` on Windows), the right one for directories
is `File.separatorChar` (`/` on Linux, `\` on Windows).

Note that this issue was already present in
[sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64)
before it was moved here; should it be fixed there too?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants